<?php

namespace app\index\validate;


use think\Validate;

class Disease extends Validate
{

    protected $rule = [
        'type_id|类型' => 'require|number|egt:1',
        'title|桥幅' => 'require|length:1,50',
        'num|构件部位及编号' => 'require|length:1,50',
        'pattern|损害类型' => 'require|length:1,50',
        'desc|外观检测描述' => 'require|length:1,50',
        'image|图片' => 'require|url',
        'memo|备注' => 'require|length:1,50',
        'position|位置' => 'require|number'
    ];

    public $rule2 = [
        'type_id|类型' => 'require|number|egt:1',
        'title|桥幅' => 'require|length:1,50',
        'num|检测部位及位置' => 'require|length:1,50',
        'pattern|设计值(mm)' => 'require|length:1,50',
        'desc|实测保护层厚度(mm)' => 'require|length:1,50',
        'image|图片' => 'require|url',
        'memo|备注' => 'require|length:1,50',
        'position|位置' => 'require|number'
    ];

    public $rule3 = [
        'type_id|类型' => 'require|number|egt:1',
        'file|文件' => 'require|url|verifyExt:thinkphp',//file文件后缀必须是xlsx
        'position|位置' => 'require|number'
    ];

    //自定义验证方法
    protected function verifyExt($value, $rule = '')
    {
        $ext = pathinfo($value, PATHINFO_EXTENSION);
        if ($ext != 'xlsx') {
            return '文件后缀必须是xlsx';
        }
        return true;
    }
    
    

}